//
//  PAActionSheetView.m
//  Testpay
//
//  Created by shen pu on 13-7-8.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PAActionSheetView.h"

@implementation PAActionSheetView
@synthesize PA_delegate;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor darkTextColor];
        self.alpha = 0.7;
        
        UILabel * titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, self.frame.size.width, 31)];
        titleLable.text = @"请选择手机号";
        titleLable.backgroundColor = [UIColor redColor];
        titleLable.textAlignment = NSTextAlignmentCenter;
        [self addSubview:titleLable];
    }
    return self;
}

- (void)getButtonCount:(int)buttonCount getPhoneNum:(NSMutableArray *)phoneArray
{
    CGSize buttonSize = CGSizeMake(self.frame.size.width-40, 31);
    
    if ([phoneArray isKindOfClass:[NSMutableArray class]] && [phoneArray count] > 1)
    {
        for (int i = 0; i < [phoneArray count]; i ++)
        {
            UIButton * phoneButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [phoneButton setTitle:[phoneArray objectAtIndex:i] forState:UIControlStateNormal];
            phoneButton.frame = CGRectMake(20, 60 + buttonSize.height*i + 20*i, buttonSize.width, buttonSize.height);
            phoneButton.backgroundColor = [UIColor redColor];
            [phoneButton addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:phoneButton];
        }
    }
}

- (void)pressButton:(UIButton *)sender
{
    if (PA_delegate)
    {
        [PA_delegate sendPhoneNum:sender.titleLabel.text];
    }
}

@end
